home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-20 / rs0422.zip / ROSEZSW / L2CONREQ.C < prev    next >
C/C++ Source or Header  |  1990-08-04  |  1KB  |  50 lines

  1. /* This routine is called to validate each Level 2 Connect Request */
  2.  
  3. #include "buffer.h"
  4. #include "iface.h"
  5. #include "timer.h"
  6. #include "ax25.h"
  7. #include "ax25l2.h"
  8. #include "data.h"
  9.  
  10. int callcmp();
  11.  
  12. extern struct ax25_addr adr[];
  13. extern unsigned char swpos;
  14. extern unsigned char numadr, numadrm;    /* Number of addresses (callsigns) */
  15. extern int control;
  16.  
  17. struct axcb *
  18. l2conreq(iface)        /* Returns axcb or NULL, may be a new axcb */
  19. struct interface *iface;
  20. {
  21.     static unsigned char i;
  22.     register unsigned char x121[8];
  23.     static struct axcb *axcb;
  24.  
  25.     if (callcmp(&adr[0],&adr[1])) return NULL;
  26.                     /* Can't connect to yourself! */
  27.  
  28.     if (numadr < 4) /* Connect request? */ {
  29.         if (swpos != 1)    return EOF;    /* Not me! */
  30.         if ((axcb = open_ax25(&adr[0],&adr[1],iface,numadrm))) {
  31.             lnk_l3_pars(axcb);
  32.         }
  33.     }
  34.     else /* Call request, set up an axcb to accept the call */ {
  35.         i=swpos+2;
  36.         x121[0]=0;
  37.         l3_adr(&adr[swpos],x121);
  38.         if (x121[0] == 0) return EOF;    /* No X.121 Address */
  39.         if ((x121[0] == 4) && (i<=numadr)) {
  40.             x121[0]=0;
  41.             l3_adr(&adr[swpos+1],x121);
  42.             if (x121[0]) i++;
  43.         }
  44.  
  45.         if ((swpos > 4) || (i<numadr)) return EOF; /* DX */
  46.         axcb = open_ax25(&adr[0],&adr[1],iface,numadrm);
  47.     }
  48.     return axcb;
  49. }
  50.